<template>
	<view class="p30">
		<view class="p30 shadow-default radius10" v-for="(item, index) in noticeList" :key="index">
			<view class="text-nowrap solid-bottom pb20">{{item.name}}</view>
			<view class="flex row-between col-center mt20">
				<text class="fs24 color8">{{item.create_time}}</text>
				<text class="fs24 color8" @click="toNoticeDetail(item)">查详情</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"noticeList",
		data() {
			return {
				noticeList: [],
				//from==1来自于朋友圈公告
				from:''
			}
		},
		onLoad(opt) {
			console.log(opt)
			if(opt.from==1) {
				this.from=opt.from
			}
			this.getData()
		},
		methods: {
			toNoticeDetail (item) {
				if(this.from==1) {
					uni.navigateTo({
						url: '/pages/home/notice/detail?id='+item.id+'&from='+this.from
					})
				}else {
					uni.navigateTo({
						url: '/pages/home/notice/detail?id='+item.id
					})
				}
				
			},
			getData () {
				let api=''
				this.from==1? api='article_list':api='announce_list'
				this.$api[api]().then(res => {
					this.noticeList = res.data.data
				})
			},
		}
	}
</script>

<style lang="scss">

</style>
